package com.nbsaas.boot.common.rest.resource;

import com.nbsaas.boot.common.api.apis.ComponentApi;
import com.nbsaas.boot.common.data.entity.Component;
import com.nbsaas.boot.common.api.domain.request.ComponentRequest;
import com.nbsaas.boot.common.api.domain.response.ComponentResponse;
import com.nbsaas.boot.common.api.domain.simple.ComponentSimple;
import com.nbsaas.boot.common.rest.convert.ComponentSimpleConvert;
import com.nbsaas.boot.common.rest.convert.ComponentEntityConvert;
import com.nbsaas.boot.common.rest.convert.ComponentResponseConvert;
import com.nbsaas.boot.common.data.repository.ComponentRepository;

import java.io.Serializable;
import com.nbsaas.boot.jpa.data.core.BaseResource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import org.springframework.data.jpa.repository.support.JpaRepositoryImplementation;

import java.util.function.Function;
/**
*   业务接口实现
*/
@Transactional
@Service
public class ComponentResource extends BaseResource<Component,ComponentResponse, ComponentSimple, ComponentRequest>  implements ComponentApi {

    @Resource
    private ComponentRepository componentRepository;

    @Override
    public JpaRepositoryImplementation<Component, Serializable> getJpaRepository() {
        return componentRepository;
    }

    @Override
    public Function<Component, ComponentSimple> getConvertSimple() {
        return new ComponentSimpleConvert();
    }

    @Override
    public Function<ComponentRequest, Component> getConvertForm() {
        return new ComponentEntityConvert();
    }

    @Override
    public Function<Component, ComponentResponse> getConvertResponse() {
        return new ComponentResponseConvert();
    }




}


